<template>
  <div class="result-box">
    <div class="result-hd">
      <div
        class="hd-item"
        v-for="(item, index) in tabList"
        :key="index"
        :class="{ cur: index == curIndex }"
        @click="handleTab(index)"
      >
        {{ item }}
      </div>
    </div>
    <div class="result-bd">
      <div class="result-grid" v-if="curIndex == 0">
        <div
          class="grid-item"
          v-for="(item, index) in (props.paramers as any)"
          :key="index"
        >
          <div class="item-value">{{ item.value }}</div>
          <div class="item-title">{{ item.name }}</div>
        </div>
      </div>
      <div class="result-img" v-if="curIndex == 1">
        <div class="img-bg">
          <div class="dot"  :style="{top:dotRef.y+'px',left:dotRef.x+'px'}"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useEventStore } from "@/store/modules/events";
const store = useEventStore();
const props = defineProps({
  previewImg: String,
  paramers: Array,
  curIndex: Number,
  showDot: Boolean,
});
const emit = defineEmits(["changeTab"]);
const tabList = ref(["实验参数", "实验现象"]);
const dotRef = computed(() => {
  return store.operate;
});

const handleTab = (index: number) => {
  emit("changeTab", index);
};
</script>
<style lang="less" scoped>
.result-box {
  .result-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .hd-item {
      width: 138px;
      height: 32px;
      background: #f2f3f5;
      border-radius: 8px 8px 0px 0px;
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 12px;
      color: #595959;
      line-height: 32px;
      text-align: center;
      font-style: normal;
      cursor: pointer;
      &.cur {
        color: #2776ff;
        background: #dae8ff;
      }
    }
  }
  .result-bd {
    .result-grid {
      padding: 12px;
      height: 234px;
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      align-items: start;
      gap: 0;
      .grid-item {
        width: 126px;
        display: flex;
        align-self: start;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative;
        .item-value {
          font-family: PingFangSC, PingFang SC;
          font-weight: 600;
          font-size: 20px;
          color: #262626;
          line-height: 26px;
          text-align: center;
          font-style: normal;
          margin-bottom: 4px;
        }
        .item-title {
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 12px;
          color: #595959;
          line-height: 16px;
          text-align: center;
          font-style: normal;
        }
        &:nth-child(2n + 1) {
          &::after {
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            content: "";
            width: 1px;
            height: 16px;
            background: #e6ebf1;
          }
        }
      }
    }
    .result-img {
      padding: 12px;
      height: 234px;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      .img-bg {
        width: 64px;
        height:64px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        &::after{
          content:"";
          width:24px;
          height:24px;
          border-radius: 50%;
          background-color: #000;
        }
      }

      .dot {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: #ff4d4f;
        position: absolute;
        top: 12px;
        left: 12px;
      }
    }
  }
}
</style>
